<template>
  <div>
    <div class="container">
      <div class="nav">
        <div>
          <a href="javascript:;" @click="$router.back()"></a>
        </div>
        <div>
          <span>资讯</span>
        </div>
        <div @click="subnav = !subnav">
          <i>&nbsp;&nbsp;&nbsp;&nbsp;</i>
          <div class="subnav" v-show="subnav">
            <router-link to="/" tag="a">首页</router-link>
            <router-link to="/news" tag="a">资讯</router-link>
            <router-link to="/video" tag="a">视频</router-link>
            <router-link to="/seek" tag="a">找车</router-link>
            <router-link to="/plaint" tag="a">汽车投诉</router-link>
          </div>
        </div>
      </div>
      <div class="tabs">
        <div><span>最新</span></div>
        <div><span>新车</span></div>
        <div><span>导购</span></div>
        <div><span>测评</span></div>
        <div><span>上海</span></div>
      </div>
      <div class="banner">
        <div class="img">
          <img src="../assets/img/news_ban.jpg" alt="" />
        </div>
        <div class="txt">爽快 智能 试驾广汽本田全新型格e:HEV</div>
        <ul>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
        </ul>
        <a href="javascript:;" class="prev"></a>
        <a href="javascript:;" class="next"></a>
      </div>
      <div class="new">
        <router-link
          tag="div"
          :to="{ path: '/topic', query: { ind: item.id } }"
          v-for="(item, index) in carNews"
          :key="index"
        >
          <div class="img">
            <img :src="item.src" alt="" />
          </div>
          <div class="txt">
            <h4>{{ item.title }}</h4>
            <span>{{ item.date }} </span>
          </div>
        </router-link>
      </div>

      <div class="ele">查看更多</div>
      <div class="search_foot">
        <div></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["carNews"],
  created() {
    this.$emit("car-show", true);
  },
  data() {
    return {
      subnav: false,
    };
  },
};
</script>

<style lang="scss" scoped>
.nav {
  height: 44px;
  background-color: #35447b;
  display: flex;
  align-items: center;

  & > div {
    &:nth-child(1) {
      text-align: left;
      flex: 1;
    }

    &:nth-child(2) {
      text-align: center;
      flex: 1;
    }

    &:nth-child(3) {
      text-align: right;
      flex: 1;
      padding-right: 10px;
      position: relative;
      i {
        display: block;
        float: right;
      }
      .subnav {
        width: 100px;
        height: 170px;
        padding: 6px;
        border-radius: 4px;
        position: absolute;
        top: 35px;
        left: 12px;
        background: rgba(0, 0, 0, 0.8);
        z-index: 9;
        a {
          width: 100px;
          height: 18px;
          padding: 8px 0;
          text-align: center;
          background-image: none;
          color: #fff;
        }

        &::before {
          content: "";
          display: block;
          position: absolute;
          top: -17px;
          left: 80px;
          border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
          border-width: 9px;
          border-style: dashed dashed solid dashed;
        }
      }
    }
  }

  div {
    a {
      display: block;
      width: 40px;
      height: 40px;
      background-image: url("../assets/img/icons1.png");
      background-position: -82px -32px;
      background-size: 400px auto;
    }

    span {
      color: #fff;
      font-size: 18px;
    }

    i {
      width: 25px;
      height: 22px;
      background-image: url("../assets/img/icons1.png");
      background-position: -175px -42px;
      background-size: 400px auto;
    }
  }
}

.tabs {
  height: 44px;
  border-top: 1px solid #fff;
  display: flex;
  background-color: #eee;

  div {
    flex: 1;
    text-align: center;
    line-height: 44px;

    span {
      padding: 8px 0;
      font-size: 18px;
      color: #999;
    }

    &:first-of-type {
      span {
        border-bottom: 2px solid #4c61b0;
      }
    }
  }
}

.banner {
  position: relative;

  .txt {
    width: 100%;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.6);
    line-height: 30px;
    color: #fff;
    text-indent: 10px;
    font-size: 12px;
    position: absolute;
    bottom: 0px;
  }

  ul {
    display: flex;
    position: absolute;
    bottom: 10px;
    right: 0;

    li {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: #e5e5e5;
      margin-right: 5px;

      &:first-of-type {
        background-color: #ff6600;
      }
    }
  }

  a {
    width: 35px;
    height: 60px;
    background-image: url("../assets/img/btn.png");
    position: absolute;
    top: 50%;
    margin-top: -30px;
    background-size: 100px auto;
    background-repeat: no-repeat;

    &:first-of-type {
      left: 5px;
      background-position: 0 center;
    }

    &:last-of-type {
      right: 5px;
      background-position: 100% center;
    }
  }
}

.new {
  height: 100%;

  & > div {
    height: 62px;
    display: flex;
    border-bottom: 1px solid #e5e5e5;
    padding: 8px 10px;

    .img img {
      width: 90px;
      height: 60px;
    }

    .txt {
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      padding: 0 10px;

      h4 {
        height: 42px;
        line-height: 20px;
        font-weight: 600;
        font-size: 16px;
        color: #333;
      }

      span {
        font-size: 12px;
        color: #999;
      }
    }
  }
}
</style>
